using Config;
using Entity;
using MoonFramework.Scripts.View.Music;
using MoonFramework.Test;
using UnityEngine;

namespace Map.MapObject.HitObject
{
    public class BushLeafObject : BaseHitMapObject
    {
        public override void Init(BaseMapBlock mapBlock, ulong id)
        {
            base.Init(mapBlock, id);
            _weaponType = WeaponType.Sickle;
        }

        public override bool DoHit(Actor actor, float dir)
        {
            if (dir >= 1.5f) return false;
            return base.DoHit(actor, dir);
        }

        public override void Hurt(ItemWeaponInfo weaponInfo)
        {
            if (weaponInfo.WeaponType == WeaponType.Sickle)
            {
                AudioManager.Instance.PlayOnShot(hurtAudioClips[Random.Range(0, hurtAudioClips.Length - 1)], transform.position).Forget();
                RotationTransform(20).Forget();
                hp -= weaponInfo.AttackValue;
                if (hp <= 0) Dead();
            }
        }
    }
}